package com.ming.stringstudy.feedbacksystem.Config;

import com.ming.stringstudy.feedbacksystem.Interceptor.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class WebConfig implements WebMvcConfigurer {
    private final CommentPageInterceptor commentPageInterceptor;
    private final UserIdAutowiredInterceptor userIdAutowiredInterceptor;

    public WebConfig(CommentPageInterceptor commentPageInterceptor,UserIdAutowiredInterceptor userIdAutowiredInterceptor) {
        this.commentPageInterceptor = commentPageInterceptor;
        this.userIdAutowiredInterceptor = userIdAutowiredInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userIdAutowiredInterceptor).addPathPatterns("/**");
        registry.addInterceptor(commentPageInterceptor).addPathPatterns("/comments");
    }
}
